﻿@model LeadMaster.ViewModels.ViewModelLeads

@using (Html.BeginForm("Create", "Leads", FormMethod.Post, new { @class = "formCreateLead" }))
{
    @Html.ValidationSummary(true)
    <fieldset style="border-style: none; width: 500px;">
        @Html.HiddenFor(m => m.Lead.UserID)
        @Html.HiddenFor(m => m.Lead.LeadStatusesID)
		@Html.HiddenFor(m => m.Lead.TotalWeeks)
        @Html.HiddenFor(model => model.Lead.ContactType)
    <div class="spacer"></div>
    <table>
        <tr>
        <td><img src="../../Images/phone_icon.png" style="height:40px; width: 40px;" id="imgCreateLeadPhone" class="commsbutton" alt="Telephone"/></td>
        <td><img src="../../Images/email_icon.png"  style="border-style:solid; height:40px; width: 40px;" id="imgCreateLeadEmail" class="commsbutton" alt="Email"/></td>
        <td><img src="../../Images/two_people_meeting.png"  style="height:40px; width: 40px;" id="imgCreateLeadMeeting" class="commsbutton" alt="Meeting"/></td>
        <td><img src="../../Images/fax_icon2.jpg"  style="height:40px; width: 40px;" id="imgCreateLeadFax" class="commsbutton" alt="Fax"/></td>
        <td><img src="../../Images/www.png"  style="height:40px; width: 40px;" id="imgCreateLeadWWW" class="commsbutton" alt="WWW"/></td>
        </tr>
    </table>
    <table>
    <tr>
    <td>@Html.Label("Salutation")</td>
    <td>@Html.LabelFor(model => model.Contact.Forename)</td>
    <td>@Html.LabelFor(model => model.Contact.Surname)</td>
    </tr>
    <tr>
    <td>                
        @Html.DropDownList("SalutationID", null, new { style = "width:180px" })
        @Html.ValidationMessageFor(model => model.Contact.SalutationID)
    </td>
    <td>
        @Html.TextBoxFor(model => model.Contact.Forename)
        @Html.ValidationMessageFor(model => model.Contact.Forename)
    </td>
    <td>
        @Html.TextBoxFor(model => model.Contact.Surname)
        @Html.ValidationMessageFor(model => model.Contact.Surname)
    </td>
    </tr>
    </table>
    <div class="editor-label">
        @Html.Label("Company")
    </div>
    <div class="editor-field">
        @Html.TextBoxFor(model => model.Company.Company, new { @class = "largetextbox" })
        @Html.ValidationMessageFor(model => model.Company.Company)
    </div>
    <div class="editor-label" style="clear:both;">
        @Html.LabelFor(model => model.Contact.Telephone)
    </div>
    <div>
        @Html.TextBoxFor(model => model.Contact.Telephone, new { @class = "largetextbox" })
        @Html.ValidationMessageFor(model => model.Contact.Telephone)
    </div>
    <div class="editor-label" style="clear:both;">
        @Html.LabelFor(model => model.Contact.Email)
    </div>
    <div>
        @Html.TextBoxFor(model => model.Contact.Email, new { @class = "largetextbox" })
        @Html.ValidationMessageFor(model => model.Contact.Email)
    </div>
    <div class="editor-label" style="clear:both;">
        @Html.Label("Interest")
    </div>
    <div>
        @Html.DropDownList("SectorID", null, new { style = "width:300px;", name="Sector.SectorID" })
        @Html.ValidationMessageFor(model => model.Sector.SectorID)
    </div>
    <div class="editor-label" style="clear:both;">
        @Html.Label("Next Contact Date")
    </div>
    <div>
        <input type="text" id="NextContactDate" name="NextContactDate" value="@(Model.NextContactDate)" />
    </div>
    <div class="editor-label" style="clear:both;">
        @Html.Label("Notes")
    </div>
    <div>
        @Html.TextAreaFor(model => model.Lead.FreeNotes, new { @class="notes", style="width:450px;"})
        @Html.ValidationMessageFor(model => model.Lead.FreeNotes)
    </div>
    <div>
    <div class="spacer"></div>
    <input type="submit" value="Create New Lead" class="bigsubmit" />
    </div>
    </fieldset>
}


<script src="~/Content/chosen/chosen.jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">
    $(document).ready(function () {
        $("#SalutationID").attr('name', 'Contact.SalutationID');
        $("#LeadStatusesID").attr('name', 'Lead.LeadStatusesID');
        $("#SectorID").attr('name', 'Sector.SectorID');

        $("#Lead_ContactType").val("T");

        $("#NextContactDate").datepicker({
            changeMonth: true,
            changeYear: true,
            regional: 'en-GB',
            dateFormat: 'dd/mm/yy'
        });

        $(".commsbutton").click(function () {
            $("#imgCreateLeadPhone").css("border-style", this.id == "imgCreateLeadPhone" ? "solid" : "none");
            $("#imgCreateLeadEmail").css("border-style", this.id == "imgCreateLeadEmail" ? "solid" : "none");
            $("#imgCreateLeadMeeting").css("border-style", this.id == "imgCreateLeadMeeting" ? "solid" : "none");
            $("#imgCreateLeadFax").css("border-style", this.id == "imgCreateLeadFax" ? "solid" : "none");
            $("#imgCreateLeadWWW").css("border-style", this.id == "imgCreateLeadWWW" ? "solid" : "none");
            switch (this.id) {
                case "imgCreateLeadPhone":
                    $("#Lead_ContactType").val("T");
                    break;
                case "imgCreateLeadEmail":
                    $("#Lead_ContactType").val("E");
                    break;
                case "imgCreateLeadMeeting":
                    $("#Lead_ContactType").val("M");
                    break;
                case "imgCreateLeadFax":
                    $("#Lead_ContactType").val("F");
                    break;
                default:
                    $("#Lead_ContactType").val("W");
                    break;
            }
        });
    });
</script>
